home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d13
/
book.exe
/
LANSHOW.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-22
|
5KB
|
181 lines
/*
// LANSHOW.C A LANtastic NET SHOW clone
//
// (c) Copyright 1990, 1991 Adrian King.
//
//
// This code was developed for inclusion in the book
// "Running LANtastic", by Adrian King, published by
// Bantam Books, October 1991.
//
// $Header: F:/LANBOOK/SRC/LAN/VCS/LANSHOW.C_V 1.0 13 Jul 1991 11:28:14 $
//
// $Log: F:/LANBOOK/SRC/LAN/VCS/LANSHOW.C_V $
//
// Rev 1.0 13 Jul 1991 11:28:14
//Initial revision.
//
// This program is a single module example showing how to use both
// the LANtastic API and the C library presented in "Running LANtastic".
//
// The program is a 'clone' of the NET SHOW function of the LANtastic
// NET utility. No attention has been paid to efficiency details.
//
// Although error messages are displayed, very little error processing
// is done.
//
// Build notes:
//
// This module must be linked with the NOS library (NOSLIB.LIB).
//
// Make sure that nos.h and noslib.h are on the INCLUDE path for the
// compiler.
//
// Borland Turbo C: tcc lanshow.c noslib.c
//
// Borland C++: bcc lanshow.c noslib.c
//
// Microsoft C: cl lanshow.c noslib.c
//
*/
// Standard DOS includes
#include "stdio.h"
#include "conio.h"
#include "process.h"
#include "dos.h"
#include "string.h"
#include "ctype.h"
// NOS specific includes
#include "nos.h"
#include "noslib.h"
// Macros
#define ERROR NOSperror("LANSHOW") // Print a NOS error message
#define TICKS 18 // Per second. Ought to be 18.2...
#ifdef __TURBOC__
unsigned _heaplen = 1000; // Smaller heap for Turbo C
#endif
//
// MAIN
//
// Display (in order):
//
// A title
// Details of this machine
// The status of record and file locking
// The status of the message service
// The LPT timeout
// The logins and redirections current on this node
// Other servers available on the network
//
// There are no parameters to this program, you run it as LANSHOW
//
void main()
{
char cpName[D_NAMESZ+2];
int nVersion;
int nLoaded;
int nAdapter;
BOOL bName;
char *cp;
int nMsgflag;
int nTimeout;
int i, j;
char cpUsername[D_NAMESZ];
char cpDevice[D_NAMESZ];
char cpPath[128];
WORD wType;
nLoaded = NOSPresence(); // See what's loaded // Check LANBIOS and REDIR present
if (nLoaded == -1){
// NOSPresence() doesn't set an error
// This error message is not a clone
printf("LANSHOW: Network not loaded\n");
exit(1);
}
// Use NOS version number in title
nVersion = NOSGetVersion();
printf("LANSHOW version %d.%02d - (C) Copyright 1991 Adrian King\n",
nVersion >> 8,
nVersion & 0xff);
// Get the node name
if (NOSGetMachineName(&cpName[2], &nAdapter, &bName) == -1)
ERROR;
cpName[0] = cpName[1] = '\\'; // Add the \\prefix and
// null terminate the name
cp = strchr(cpName, ' ');
if (cp != NULL)
*cp = '\0';
// Report node details
printf("Machine %s is being used as a %s%s\n",
&cpName[2],
(nLoaded & 0x08)?"Redirector":"",
(nLoaded & 0x40)?" and a Server":"");
// Report on locking status
nLoaded = NOSSharePresence();
printf("File and record locking is currently %s\n",
(nLoaded == -1)?"ENABLED":"DISABLED");
// Report on message service
if (NOSGetMsgFlag(&nMsgflag) == -1)
ERROR;
printf("Unsolicited messages will %s and %s\n",
(nMsgflag & MPB_beep)?"BEEP":"NOT BEEP",
(nMsgflag & MPB_auto_pop_up)?"POP-UP":"NOT POP-UP");
// Report on LPT timeout
if (NOSGetLPTTimeout(&nTimeout) == -1)
ERROR;
printf("LPT timeout in seconds: %d\n", nTimeout / TICKS);
// Report on logins
i = 0;
while (NOSGetLogin(&i, &cpName[2], &nAdapter) != -1){
cp = strchr(cpName, ' '); // Null terminate the server name
if (cp != NULL)
*cp = '\0';
// Get login name
if (NOSGetUserName(&i, cpUsername, &nAdapter) != -1)
printf("Logged into %s as %s on adapter %d\n",
cpName, cpUsername, nAdapter);
i++; // Increment server index
};
// Report on redirections
j = 0;
while (NOSGetRedirDevice(j, cpDevice, cpPath, &wType) != -1){
printf("%s %s is redirected to %s\n",
((wType & 0xFF) == 3)?"Printer":"Disk",
cpDevice,
cpPath);
j++; // Increment device index
}
// Report on other available servers
i = 0;
while (NOSGetServer(&i, &cpName[2], &nAdapter) != -1){
printf("Server %s is available on adapter %d\n", cpName, nAdapter);
i++;
};
exit(0); // Normal exit
}